package com.deep.deepenterpise.common;

import com.deep.deepenterpise.common.util.DrAESUtil;
import com.deep.deepenterpise.common.util.DrCommonUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;

/**
 * @author xyz
 * @version 1.0
 * @title DrGasAESCommon
 * @description
 * @create 2024/4/24 11:01
 */
@Slf4j
public class DrAESCommon {
    private static final String VIPARA = "deeplinewms2022W";
    private static final String ASE_KEY = "deeplinewms2022W";

    /**
     * @return java.lang.String
     * @Auth xyz
     * @Desc //TODO 解析token获取用户uuid
     * @Time 13:16 2024/6/13
     * @Param [token]
     */
    public static String parseToken(String token) {
        String drLoginInfo;
        try {
            drLoginInfo = DrAESUtil.decryptNoBase64(token, ASE_KEY, VIPARA);
        } catch (Exception e) {
            log.error("[登录Token解析失败，解密失败]-------" + DrCommonUtil.drGetStackTraceInfo(e));
            return null;
        }
        if (StringUtils.isBlank(drLoginInfo)) {
            return null;
        }
        String[] split = drLoginInfo.split("\\.");
        if (split.length < 4) {
            return null;
        }
        return split[3];
    }
}
